package instan_srv

import (
	"fmt"
	apis2 "gluenet/pkg/apis"
	"strings"
)

func InstanceReport(ctx *apis2.GlueContext) {
	var (
		err     error
		key     string
		service string
	)
	key = ctx.WebContext.URLParam("guid")
	service = ctx.WebContext.URLParam("service")

	ctx.Logger.Debugf("get agent guid: %v %v", key, service)

	data, ok := ctx.Report.Get(strings.Join([]string{key, service}, "_"))
	if !ok {
		ctx.Logger.Errorf("data not exist %v", err)
		ctx.WebContext.JSON(apis2.ResponseReqErr(fmt.Errorf("data not exist %v", err), nil))
		return
	}

	ctx.WebContext.JSON(apis2.ResponseOK(data))
}
